<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    class Phone {
      get price() {
        console.log('get price');
        return '调用了get'
      }
      set price(value) {
        console.log('set price');
      }
    }

    let p = new Phone();

    console.log(p.price); // 获取 price 属性就会调用对应的 get 方法

    p.price = 888;        // 设置 price 属性就会调用对应的 set 方法


  </script>
</body>

</html>